package com.ruoyi.zhifubao.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.zhifubao.domain.SysTestZhifubao;
import com.ruoyi.zhifubao.service.ISysTestZhifubaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 支付宝测试Controller
 *
 * @author yanghua
 * @date 2020-10-13
 */
@RestController
@RequestMapping("/zhifubao")
public class SysTestZhifubaoController extends BaseController {
    @Autowired
    private ISysTestZhifubaoService sysTestZhifubaoService;

    /**
     * 查询支付宝测试列表
     */
    @PreAuthorize("@ss.hasPermi('zhifubao:zhifubao:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysTestZhifubao sysTestZhifubao) {
        startPage();
        List<SysTestZhifubao> list = sysTestZhifubaoService.selectSysTestZhifubaoList(sysTestZhifubao);
        return getDataTable(list);
    }

    /**
     * 导出支付宝测试列表
     */
    @PreAuthorize("@ss.hasPermi('zhifubao:zhifubao:export')")
    @Log(title = "支付宝测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysTestZhifubao sysTestZhifubao) throws IOException {
        List<SysTestZhifubao> list = sysTestZhifubaoService.selectSysTestZhifubaoList(sysTestZhifubao);
        ExcelUtil<SysTestZhifubao> util = new ExcelUtil<SysTestZhifubao>(SysTestZhifubao.class);
        util.exportExcel(response, list, "zhifubao");
    }

    /**
     * 获取支付宝测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('zhifubao:zhifubao:query')")
    @GetMapping(value = "/{zfbId}")
    public AjaxResult getInfo(@PathVariable("zfbId") Long zfbId) {
        return AjaxResult.success(sysTestZhifubaoService.selectSysTestZhifubaoById(zfbId));
    }

    /**
     * 新增支付宝测试
     */
    @PreAuthorize("@ss.hasPermi('zhifubao:zhifubao:add')")
    @Log(title = "支付宝测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysTestZhifubao sysTestZhifubao) {
        return toAjax(sysTestZhifubaoService.insertSysTestZhifubao(sysTestZhifubao));
    }

    /**
     * 修改支付宝测试
     */
    @PreAuthorize("@ss.hasPermi('zhifubao:zhifubao:edit')")
    @Log(title = "支付宝测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysTestZhifubao sysTestZhifubao) {
        return toAjax(sysTestZhifubaoService.updateSysTestZhifubao(sysTestZhifubao));
    }

    /**
     * 删除支付宝测试
     */
    @PreAuthorize("@ss.hasPermi('zhifubao:zhifubao:remove')")
    @Log(title = "支付宝测试", businessType = BusinessType.DELETE)
    @DeleteMapping("/{zfbIds}")
    public AjaxResult remove(@PathVariable Long[] zfbIds) {
        return toAjax(sysTestZhifubaoService.deleteSysTestZhifubaoByIds(zfbIds));
    }
}
